<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{admin/header :: header-fragment}"/>
    <link rel="stylesheet" th:href="@{/admin/plugins/daterangepicker/daterangepicker.css}">
</head>
</header>
<style>
    .ui-jqgrid tr.jqgrow td {
        white-space: normal !important;
        height: auto;
        vertical-align: text-top;
        padding-top: 2px;
    }
</style>
<body class="hold-transition sidebar-mini">
<div class="wrapper" id="app">
    <!-- Navbar -->
    <th:block th:insert="~{admin/header :: navbar-fragment}"/>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <th:block th:insert="~{admin/sidebar :: sidebar-fragment(${path})}"/>

    <!-- Content Wrapper. Contains 图标content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <!--                        <h1 class="m-0 text-dark">carousels</h1>-->
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">优惠卷管理</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content-header -->

        <!-- Main content -->
        <div class="content">
            <div class="container-fluid">
                <div class="card card-primary card-outline">
                    <div class="card-header">
                        <h3 class="card-title">优惠卷管理</h3>
                    </div>

                    <!-- search-content -->
                    <div class="search-content">
                        <form class="form-inline" id="search-form" action="javascript:;">
                            <div class="form-group">
                                <label class="">优惠劵名称</label>
                                <input type="text" class="form-control" id="couponName">
                            </div>
                            <div class="form-group">
                                <label class="m-l">优惠劵类型</label>
                                <select class="form-control" id="couponType">
                                    <option value="" selected>请选择</option>
                                    <option value="0">通用卷</option>
                                    <option value="1">注册赠卷</option>
                                    <option value="2">兑换卷</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="m-l">优惠劵状态</label>
                                <select class="form-control" id="status">
                                    <option value="" selected>请选择</option>
                                    <option value="0">上架</option>
                                    <option value="1">过期</option>
                                    <option value="2">下架</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="m-l">创建时间</label>
                                <input type="text" class="w-210 form-control" id="createTime">
                            </div>
                            <button type="button" class="btn btn-success m-l" onclick="reload()">搜索</button>
                            <button type="button" class="btn btn-info m-l"
                                    onclick="javascrip:$('#search-form')[0].reset();">重置
                            </button>
                        </form>
                    </div>
                    <!-- /search-content -->

                    <!-- .card-body -->
                    <div class="card-body">
                        <div class="grid-btn">
                            <button class="btn btn-info" @click="couponAdd()"><i
                                    class="fa fa-plus"></i>&nbsp;新增
                            </button>
                            <button class="btn btn-info" @click="couponEdit()"><i
                                    class="fa fa-pencil-square-o"></i>&nbsp;修改
                            </button>
                            <button class="btn btn-danger" @click="deleteCoupon()"><i
                                    class="fa fa-trash-o"></i>&nbsp;删除
                            </button>
                        </div>
                        <table id="jqGrid" class="table table-bordered">
                        </table>
                        <div id="jqGridPager"></div>
                    </div>
                    <!-- /.card-body -->

                </div>
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content -->
        <div class="content">
            <!-- 模态框（Modal） -->
            <div class="modal fade" id="couponModal" tabindex="-1" role="dialog"
                 aria-labelledby="couponModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                    aria-hidden="true">&times;</span></button>
                            <h6 class="modal-title">{{title}}</h6>
                        </div>
                        <div class="modal-body">
                            <form id="couponForm">
                                <div class="form-group">
                                    <div class="alert alert-danger" id="edit-error-msg" style="display: none;">
                                        错误信息展示栏。
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="name" class="col-md-3 control-label">优惠卷名称:</label>
                                    <input type="text" class="col-md-9 form-control" id="name" v-model="form.name"
                                           placeholder="*请输入优惠卷名称" required="true">
                                </div>
                                <div class="form-group row">
                                    <label for="total" class="col-md-3 control-label">优惠卷数量:</label>
                                    <input type="number" class="col-md-9 form-control" id="total"
                                           v-model="form.couponTotal"
                                           placeholder="*请输入优惠卷数量，如果是0则是无限量" required="true">
                                </div>
                                <div class="form-group row">
                                    <label for="discount" class="col-md-3 control-label">优惠金额:</label>
                                    <input type="number" class="col-md-9 form-control" id="discount"
                                           v-model="form.discount"
                                           placeholder="*请输入优惠金额">
                                </div>
                                <div class="form-group row">
                                    <label for="min" class="col-md-3 control-label">最少消费金额:</label>
                                    <input type="number" class="col-md-9 col-md-9 form-control" id="min"
                                           v-model="form.min"
                                           placeholder="*请输入最少消费金额">
                                </div>
                                <div class="form-group row">
                                    <label for="days" class="col-md-3 control-label">有效天数:</label>
                                    <input type="number" class="col-md-9 form-control" id="days" v-model="form.days"
                                           placeholder="*请输入最少消费金额">
                                </div>
                                <div class="form-group row">
                                    <label class="col-md-3 control-label">领取限制数量:</label>
                                    <div class="col-md-9 btn-group-sm btn-group-toggle">
                                        <label :class="form.couponLimit == 0?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.couponLimit" :value="0" checked>无限制
                                        </label>
                                        <label :class="form.couponLimit == 1?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.couponLimit" :value="1">限领一张
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-md-3 control-label">赠送类型:</label>
                                    <div class="col-md-9 btn-group-sm btn-group-toggle">
                                        <label :class="form.couponType == 0?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.couponType" :value="0" checked>通用卷
                                        </label>
                                        <label :class="form.couponType == 1?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.couponType" :value="1">注册赠卷
                                        </label>
                                        <label :class="form.couponType == 2?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.couponType" :value="2">优惠码兑卷
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-md-3 control-label">状态:</label>
                                    <div class="col-md-9 btn-group-sm btn-group-toggle">
                                        <label :class="form.status == 0?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.status" :value="0" checked>可用
                                        </label>
                                        <!--<label :class="form.status == 1?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.status" :value="1">过期
                                        </label>-->
                                        <label :class="form.status == 2?'btn btn-info active':'btn btn-info'">
                                            <input type="radio" v-model="form.status" :value="2">下架
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-md-3 control-label">限制类型:</label>
                                    <div class="col-md-9 btn-group-sm btn-group-toggle">
                                        <label :class="form.goodsType == 0?'btn btn-info active':'btn btn-info'"
                                               @click="changeGoodsType(0)">
                                            <input type="radio" v-model="form.goodsType" :value="0">全商品
                                        </label>
                                        <label :class="form.goodsType == 1?'btn btn-info active':'btn btn-info'"
                                               @click="changeGoodsType(1)">
                                            <input type="radio" v-model="form.goodsType" :value="1">类目限制
                                        </label>
                                        <label :class="form.goodsType == 2?'btn btn-info active':'btn btn-info'"
                                               @click="changeGoodsType(2)">
                                            <input type="radio" v-model="form.goodsType" :value="2">商品限制
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group row" v-show="form.goodsType != 0">
                                    <label class="col-md-3 control-label">{{goodsValueLabel}}</label>
                                    <input type="text" class="col-md-9 form-control" v-model="form.goodsValue"
                                           :placeholder="'*请输入' + goodsValueLabel + ',多个用逗号分隔'">
                                </div>
                                <div class="form-group row">
                                    <label for="desc" class="col-md-3 control-label">优惠卷简介:</label>
                                    <textarea rows="2" class="col-md-9 form-control" id="desc" v-model="form.couponDesc"
                                              placeholder="请输入优惠卷简介"></textarea>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary" @click="save">确认</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.modal -->
        </div>
    </div>
    <!-- /.content-wrapper -->
    <!-- 引入页脚footer-fragment -->
    <div th:replace="~{admin/footer::footer-fragment}"></div>
</div>
<!-- jQuery -->
<script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
<!-- jQuery UI 1.11.4 -->
<script th:src="@{/admin/plugins/jQueryUI/jquery-ui.min.js}"></script>
<!-- Bootstrap 4 -->
<script th:src="@{/admin/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/admin/dist/js/adminlte.min.js}"></script>
<!-- jqgrid -->
<script th:src="@{/admin/plugins/jqgrid/jquery.jqGrid.min.js}"></script>
<script th:src="@{/admin/plugins/jqgrid/grid.locale-cn.js}"></script>

<!-- sweetalert -->
<script th:src="@{/admin/plugins/sweetalert/sweetalert.min.js}"></script>
<script th:src="@{/admin/dist/js/public.js}"></script>
<script th:inline="javascript"> var _ctx = [[@{/}]]; </script>
<script th:src="@{/admin/plugins/daterangepicker/moment.min.js}"></script>
<script th:src="@{/admin/plugins/daterangepicker/daterangepicker.js}"></script>
<script th:src="@{/admin/plugins/vue-2.6.11/vue-v2.6.11.min.js}"></script>
<script th:src="@{/admin/dist/js/newbee_mall_coupon.js}"></script>
</body>
</html>
